/*
 *  Copyright (c) 2022 ZhuHai Jieli Technology Co.,Ltd.
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

#include "typedef.h"
void delay_us(unsigned int us)
{
    if (JL_SFC->CON & BIT(0)) {
        us *= 320000000 / 1000000 / 8;
    } else {
        us *= 320000000 / 1000000 / 4;
    }

    while (us--) {
        asm volatile("nop");
    }
}
__attribute__((weak)) void udelay(unsigned int t)
{
    delay_us(t);
}

__attribute__((weak)) void mdelay(unsigned int ms)
{
    delay_us(1000 * ms);
}

void delay(unsigned int ncycle)
{
    while (ncycle--) {
        asm volatile("nop");
    }
}

